package earogya.ehr.medical_records.ws;

import java.io.IOException;

import ca.uhn.hl7v2.HL7Exception;

public class MedicalRecordsServiceInterface {

	public String getMedicalRecords(String message) throws HL7Exception, IOException{
		HL7MessageHandler h=new HL7MessageHandler();
		/*String msga01 = "MSH|^~\\&|^EAFE|^CSTH|^PVS|^CSTH|20110831101817.778+0550||ADT^A01|||2.5.1\r"+
						"PID||507\r"+
		"NK1||Silva^Chamendri^Tharaka^^Miss.|^Father|&street 1&86^city 1^city 2^^^sri lanka|0113456789^^^sdfmsk@jskhdfj.sdd||||||||||||||||||||||||||||||||878032764v\r"+
		"PV1|||^7^6||||||12345||||||||12345|||||||||||||||||||||||||||20110831000000+0550\r"+
		"PV2|||^reason\r"+
		"OBX||ST|||observation 11|||||||||20110831000000+0550||12345\r"+
		"DG1||||diagnosis 11|20110831000000+0550|||||||||||12345\r";*/
		
		/*String msga08 = "MSH|^~\\&|HIS|RIH|EKG|EKG|199904140038||ADT^A08||P|2.5.1\r"
			// +"PID|0001|00009874|00001122|A00977|SMITH^JOHN^M|MOM|19581119|F|NOTREAL^LINDA^M|C|564 SPRING ST^^NEEDHAM^MA^02494^US|0002|(818)565-1551|(425)828-3344|E|S|C|0000444444|252-00-4414||||SA|||SA||||NONE|V1|0001||D.ER^50A^M110^01|ER|P00055|11B^M011^02|070615^BATMAN^GEORGE^L|555888^NOTREAL^BOB^K^DR^MD|777889^NOTREAL^SAM^T^DR^MD^PHD|ER|D.WT^1A^M010^01|||ER|AMB|02|070615^NOTREAL^BILL^L|ER|000001916994|D||||||||||||||||GDD|WA|NORM|02|O|02|E.IN^02D^M090^01|E.IN^01D^M080^01|199904072124|199904101200|199904101200||||5555112333|||666097^NOTREAL^MANNY^P\r"
			 +"PV1|||||200||||777889||||||||070615|||||||||||||||||||||||8_04|02|||199904111200|||||||||\r"
			 +"OBX||ST|||low body temperatue|||||||||201105250938||777889|\r"
			 +"DG1||||no fever|201105250938|||||||||||777889||||";*/
		
		/*String msga11 = "MSH|^~\\&|HIS|RIH|EKG|EKG|199904140038||ADT^A11||P|2.5.1\r"
			// +"PID|0001|00009874|00001122|A00977|SMITH^JOHN^M|MOM|19581119|F|NOTREAL^LINDA^M|C|564 SPRING ST^^NEEDHAM^MA^02494^US|0002|(818)565-1551|(425)828-3344|E|S|C|0000444444|252-00-4414||||SA|||SA||||NONE|V1|0001||D.ER^50A^M110^01|ER|P00055|11B^M011^02|070615^BATMAN^GEORGE^L|555888^NOTREAL^BOB^K^DR^MD|777889^NOTREAL^SAM^T^DR^MD^PHD|ER|D.WT^1A^M010^01|||ER|AMB|02|070615^NOTREAL^BILL^L|ER|000001916994|D||||||||||||||||GDD|WA|NORM|02|O|02|E.IN^02D^M090^01|E.IN^01D^M080^01|199904072124|199904101200|199904101200||||5555112333|||666097^NOTREAL^MANNY^P\r"
			 +"NK1|000|silva^chamendri|SPOUSE|&2nd lane&4^Nelumpura South^Ratmalana^^^Sri Lanka^|(900)485-5344^^^cjasdb@gjsd.sd^^^011232423||||||||||||||||||||||||||||||||878032764v||\r"
			 +"PV1|||||200||||777889||||||||070615|||||||||||||||||||||||6_30|02|||199904111200|||||||||\r"
			 +"OBX||ST|||high body temperature|||||||||201105221045||777889|\r"
			 +"DG1||||fever|201105212221|||||||||||777889||||";*/
		
		/*String mgs17= "MSH|^~\\&|HIS|RIH|EKG|EKG|20050110045502||ADT^A17||P|2.5.1\r"
			 +"EVN|A17|20050110045502|||||\r"
			 +"PV1|||||250||||777889||||||||070615|||||||||||||||||||||||8_3|02|||199904111200|||||||||\r"
			 +"PV1|||||300||||777889||||||||070615|||||||||||||||||||||||8_4|02|||199904111200|||||||||\r";*/
		
		/*String msga61="MSH|^~\\&|HIS|RIH|EKG|EKG|199904140038||ADT^A61||P|2.5.1\r"
			+"EVN|A61|20050110045502|||||\r"
			+"PV1|||||300||||222222||||||||070615|||||||||||||||||||||||8_3|02|||199904111200|||||||||\r";*/
		
		/*String mgs="MSH|^~\\&|||||200701011539||QRY^A19|||2.5.1\r"
		+"QRD||||||||250|^old admissions";*/
		String newMessage=this.modifyMessage(message);
		String ack=h.parser(newMessage);
		return ack;
	}
	
	private String modifyMessage(String message){
		String newMessage=null;
		newMessage=message.replaceAll("\n", "\r");
		return newMessage;
	}
	
	public String echo(String name){
		return name;
	}
	
}
